export default {

  //过滤状态
  appStatus(val) {
    switch (val) {
      case 0:
        return '正常';
      case 1:
        return '异常';
      default:
        return '未获取到状态'
    }
  },

    //过滤支付方式
    payStatus(val) {
      val = parseInt(val);
      switch (val) {
        case 1:
          return '微信支付';
        case 2:
          return '支付宝支付';
        default:
          return '未获取到状态'
      }
    },
     
    //过滤价格
    priceStatus(val) {
      let realVal = parseFloat(val).toFixed(0)
      return realVal
    },

    //过滤会员类型
    mealStatus(val) {
      switch (val) {
        case "200":
          return '初级会员';
        case "201":
          return '中级会员';
        case "202":
          return '高级会员';
        default:
          return '未获取到状态'
      }
    },


    //过滤会员套餐
    memberStatus(val) {
      switch (val) {
        case "200":
          return '初级会员套餐';
        case "201":
          return '中级会员套餐';
        case "202":
          return '高级会员套餐';
        default:
          return '未获取到状态'
      }
    },
  
  //过滤时间
  filterDate(val) {
    var date = new Date(val);
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? '0' + m : m;
    var d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    return y + '-' + m + '-' + d;
  },

  datePipe (dateNum, type) {
    if (dateNum === undefined) {
      return "";
    }
    const date = new Date(dateNum);
  
    const year = date.getFullYear();
    let month = (date.getMonth() + 1).toString();
    if (month.length === 1) {
      month = 0 + month;
    }
    let day = date.getDate().toString();
    if (day.length === 1) {
      day = 0 + day;
    }
    // let hour = date.getHours();
    let hour = date.getHours().toString();
    if (hour.length === 1) {
      hour = 0 + hour;
    }
    let minutes = date.getMinutes().toString();
    if (minutes.length === 1) {
      minutes = 0 + minutes;
    }
    let seconds = date.getSeconds().toString();
    if (seconds.length === 1) {
      seconds = 0 + seconds;
    }
    const week = {
      0: "星期天",
      1: "星期一",
      2: "星期二",
      3: "星期三",
      4: "星期四",
      5: "星期五",
      6: "星期六",
    };
    const todayWeek = week[date.getDay()];
  
    const timeMap = {
      1: `${year}/${month}/${day} ${hour}:${minutes}:${seconds}`,
      2: `${year}年${month}月`,
      3: `${year}-${month}-${day} ${hour}时`,
      4: `${year}年${month}月${day}日`,
      5: `${year}-${month}-${day} ${hour}:${minutes}:${seconds}`,
      6: `${year}-${month}-${day} ${hour}:${minutes}:${seconds} ${todayWeek}`,
      7: `${year}-${month}-${day}T${hour}:${minutes}`,
      8: `${year}-${month}-${day} ${hour}:${minutes}:${seconds} (${todayWeek})`,
      9: `${minutes}:${seconds}`,
    };
    return timeMap[type];
  },

   //超出文本过滤
   ellipsis(value, limit) {
    if (!value) return ''
    if (value.length > limit) {
      return value.slice(0, limit) + '...'
    }
    return value
  }

  
}

